package com.xydpeng.rpc.registry;

import com.xydpeng.rpc.registry.enums.RegistryType;
import com.xydpeng.rpc.registry.support.NacosRegistryService;

/**
 * @author xydpeng
 * @version v1.0
 * @date: 2023/4/8
 * @description:
 */
public class RegistryFactory {

    private static volatile RegistryService registryService;

    public static RegistryService getInstance(String registryAddr,RegistryType type) {
        if (registryService == null) {
            synchronized (RegistryFactory.class) {
                if (registryService == null) {
                    switch (type) {
                        case NACOS:
                            registryService = new NacosRegistryService(registryAddr);
                            break;
                        case ZOOKEEPER:
                            //registryService = new ZookeeperRegistryService(registryAddr);
                            break;
                    }
                }
            }
        }
        return registryService;
    }


    private RegistryFactory() {
    }
}
